package org.yxj.requestlib.bean;

import com.google.gson.Gson;
import java.util.Map;
import okhttp3.MediaType;
import okhttp3.RequestBody;

public class PostData {
    /**
     * @param map
     * @return
     */
    public static RequestBody postStrContentRequestBody(Map<String, Object> map){
        String content=new Gson().toJson(map);
        return  RequestBody.create(MediaType.parse("application/json; charset=utf-8"), content);
    }

    /**
     * 表单形式上传
     * @param map
     * @return
     */
    public static RequestBody postFormContentRequestBody(Map<String, Object> map){
        String content=new Gson().toJson(map);
        return RequestBody.create(MediaType.parse("application/x-www-form-urlencoded;charset=gbk"),content);
    }

    public static RequestBody getPostSendImgRequestBody(Map<String, Object> map){
        String content=new Gson().toJson(map);
        return  RequestBody.create(MediaType.parse("application/json; charset=utf-8"), content);
    }

}
